package _2025_4_23;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class MapSever extends UDPEchoSever{
    //中译英
    private Map<String,String>map;
    //初始化
    public MapSever(int pase) throws SocketException {
        super(pase);
        //初始化字典内容
        map=new HashMap<>();
        map.put("狗","dog");
        map.put("猪","pig");
        map.put("猫头鹰","owl");
        map.put("鸡","chicken");
    }

    @Override
    protected String process(String request) {
        String key=map.getOrDefault(request,"没有查到");
        return key;
    }

    public static void main(String[] args) throws IOException {
        MapSever mapSever=new MapSever(8888);
        mapSever.start();
    }
}
